package com.cu.simpleerp.frame;

import com.cu.simpleerp.frame.session.SessionManager;
import com.cu.simpleerp.frame.session.SessionManagerUtil;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author jintian
 * @date 2018/11/1 11:19
 */
@Component
public class SystemInit implements ApplicationContextAware {

    @Value("${spring.session.manager-name}")
    private String sessionMangerName;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        SessionManagerUtil.setSessionManager((SessionManager)applicationContext.getBean(sessionMangerName));
    }
}
